import axios from 'axios'
const REGISTER_SUCCESS = 'REGISTER_SUCCESS'
const ERRROR_MSG = 'ERROR_MSG'

function errMsg(msg) {
	return {msg, type: ERRROR_MSG}
}

const user = {
	state: {
		isAuth: '',
		msg: '',
		userName: '',
		pwd: '',
		value: ''
	},
	mutations: {
		user(state) {
			return state
		},
		register(state, userName, pwd, repeatPwd, value) {
			if (!userName || !pwd || !repeatPwd) {
				return errMsg('用户名密码不能为空')
			}
			if (pwd !== repeatPwd) {
				return errMsg('密码输入不一致')
			}

		}
	},
	action: {
		user({commit}) {
			commit('user')
		},
		register({
			commit
		}, userName, pwd, repeatPwd, value) {

			commit('register')
		}
	}
}
// const register = {
// 	state: {},
// 	mutations: {
// 		increment(state, payload) {
// 			return state
// 		}
// 	},
// 	action: {
// 		user({commit}) {
// 			commit('increment')
// 		}
// 	}
// }